#!/usr/bin/env python
# encoding: utf-8
"""
@author: shura
@position: saber
@contact: 2209032305@qq.com
@file: 125isPalindrome.py
@time: 2019/3/14 16:07
@desc:
"""
class Solution(object):
    def isPalindrome(self, s):
        """
        :type s: str
        :rtype: bool
        """
        i, j = 0, len(s)-1
        while i <= j:
            while not s[i].isdigit() and not s[i].isalpha() or s[i].isspace():
                i += 1
                if i >= j: return True
            while not s[j].isdigit() and not s[j].isalpha() or s[j].isspace():
                j -= 1
                if j <= i: return True
            a,b = s[i],s[j]
            if s[i] == s[j]:
                i += 1
                j -= 1
            elif s[i].isalpha and s[j].isalpha():
                if s[i].upper() == s[j].upper():
                    i += 1
                    j -= 1
                else:
                    return False
            else:
                return False
        return True

s = Solution()
print(s.isPalindrome("A man, a plan, a canal: Panama"))